package com.yupi.springbootinit.config;

import com.yupi.springbootinit.utils.DateUtils;
import io.github.briqt.spark4j.SparkClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 讯飞星火ai配置类
 */
@Configuration
@ConfigurationProperties(prefix = "xunfei.client")
@Data
public class XingHuoAiConfig {
    private String appid;
    private String apiKey;
    private String apiSecret;

    @Bean
    public SparkClient sparkClient() {
        String rfc1123 = DateUtils.toRFC1123();
        String tmp = "host: " + "spark-api.xf-yun.com" + "\n";
        tmp += "date: " + rfc1123 + "\n";
        tmp += "GET " + "/v3.5/chat" + " HTTP/1.1";
        SparkClient sparkClient = new SparkClient();
        sparkClient.appid = appid;
        sparkClient.apiKey = apiKey;
        sparkClient.apiSecret = apiSecret;
        return sparkClient;
    }

}
